package net.onceface.core.domain;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import net.onceface.infra.domain.AbstractEntity;
import net.onceface.infra.domain.NamedParameters;

/**
 * 订单中的商品
 * **/
@Entity
@Table(name = "SYS_ORDER_PRODUCT")
public class OrderProduct extends AbstractEntity{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8407098633698670568L;
	
	@Column(name = "ORDER_ID")
	private Long orderId;
	
	@Column(name = "PRODUCT_ID")
	private Long productId;
	
	@Column(name = "PICTURE")
	private String picture;
	
	@Column(name = "PRICE")
	private double price;
	
	@Column(name = "NAME")
	private String name;
	
	@Column(name = "QUANTITY")
	private int quantity;
	
	@Column(name = "SPEC_ID")
	private Long specId;
	
	@Column(name = "SPEC_NAME")
	private String specName;
	
	public OrderProduct(){}
	
	public OrderProduct(Long productId, String picture, 
			double price, String name, String specName){
		this.productId = productId;
		this.picture = picture;
		this.price = price;
		this.name = name;
		this.specName = specName;
	}

	public static List<OrderProduct> findByOrderId(Long orderId){
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("orderId", orderId);
		return getRepository()
				.findByProperties(OrderProduct.class, NamedParameters.create(param));
	}
	public Long getOrderId() {
		return orderId;
	}

	public void setOrderId(Long orderId) {
		this.orderId = orderId;
	}

	public Long getProductId() {
		return productId;
	}

	public void setProductId(Long productId) {
		this.productId = productId;
	}

	public String getPicture() {
		return picture;
	}

	public void setPicture(String picture) {
		this.picture = picture;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getQuantity() {
		return quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public Long getSpecId() {
		return specId;
	}

	public void setSpecId(Long specId) {
		this.specId = specId;
	}

	public String getSpecName() {
		return specName;
	}

	public void setSpecName(String specName) {
		this.specName = specName;
	}

	@Override
	public String[] businessKeys() {
		// TODO Auto-generated method stub
		return null;
	}

}
